package app.sceledroid.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.TextView;
import app.sceledroid.entity.Course;
import app.sceledroid.R;

public class CourseAdapter extends ArrayAdapter<Course> {

	private ArrayList<Course> courses;

	public CourseAdapter(Context context, int textViewResourceId,
			ArrayList<Course> courses) {
		super(context, textViewResourceId, courses);
		this.courses = courses;

		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			Context context = super.getContext();
			LayoutInflater vi = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.main_course_item, null);
		}
		Course c = courses.get(position);
		if (c != null) {

			Log.d("DEBUG", v.findViewById(R.id.courseName).toString());

			TextView text = (TextView) v.findViewById(R.id.courseName);
			// if (text != null) {
			text.setText(c.getName());
			text.setTextSize(25);

		}
		return v;
	}

}
